package com.sxhuayuan.parking.job;

import java.time.LocalDate;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.sxhuayuan.parking.task.ProfitStatisticsTask;

/**
 * 代理分润统计定时任务
 * 
 * @author 何龙
 * @create 2019-04-25 13:51
 */
@Component
@Lazy(false)
public class ProfitStatisticsJob {

	Logger log = LoggerFactory.getLogger(getClass());

	@Resource(name = "taskExecutor")
	TaskExecutor taskExecutor;

	/**
	 * 每天00:00:00 统计前一天代理分润
	 */
	@Scheduled(cron = "0 0 0 * * ?")
	public void agentProfitStatisticsJob() {
		log.debug("分润统计job添加");
		try {
			LocalDate date = LocalDate.now().minusDays(1);
			taskExecutor.execute(new ProfitStatisticsTask(date));
			log.debug("分润统计job添加成功");
		} catch (Exception e) {
			log.error("", e);
		}
	}

}
